function []=xcorr_act_pupil(ROI_act_ms,pupil_diam,pupil_pos,iframe_times,l_aux_data)

% act=ftfil(ROIs(sel_roi).activity,18,0,10);
% act=psmooth(act);
% act=act/median(act);
% 
% [ROI_act_ms]=map_ROI_act_to_aux_data(act,frame_times,length(aux_data));

[pupil_diam_ms]=map_ROI_act_to_aux_data(pupil_diam,iframe_times,l_aux_data);
[pupil_pos_ms]=map_ROI_act_to_aux_data(pupil_pos(1,:),iframe_times,l_aux_data);

xc_act_pupil=xcorr(ROI_act_ms,pupil_diam_ms);

[~,max_pos]=max(xc_act_pupil);

max_pos-round(length(xc_act_pupil)/2)

figure;
set(gcf,'position',[-658 55 3258 420]);
set(gcf,'color','k')
axes('position',[0 0 1 1]);
hold on
plot(ROI_act_ms,'w')
plot(2*pupil_diam_ms/median(pupil_diam_ms)-1,'m','linewidth',2)
plot(4*pupil_pos_ms/median(pupil_pos_ms)-3,'r','linewidth',2)
axis tight
axis off
